/*
 * Input.java
 *
 * Created on April 12, 2006, 9:26 PM
 */

/**
 *
 * @author  Sujal Bista
 */
public class Input extends javax.swing.JDialog {
    
    private Summary finalSummary;
    
    /** Creates new form Input */
    public Input(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        NanduScoringGroup = new javax.swing.ButtonGroup();
        jPanel2 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        nameL = new javax.swing.JLabel();
        mistakeL = new javax.swing.JLabel();
        eventL = new javax.swing.JLabel();
        deductionL = new javax.swing.JLabel();
        finalScoreL = new javax.swing.JLabel();
        scoreBL = new javax.swing.JLabel();
        groupGenderL = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        mistakeT = new javax.swing.JTextArea();
        scoreCL = new javax.swing.JLabel();
        scoreAL = new javax.swing.JLabel();
        genderF = new javax.swing.JTextField();
        eventF = new javax.swing.JTextField();
        nameF = new javax.swing.JTextField();
        scoreAF = new javax.swing.JTextField();
        scoreBF = new javax.swing.JTextField();
        scoreCF = new javax.swing.JTextField();
        deductionF = new javax.swing.JTextField();
        finalF = new javax.swing.JTextField();
        Publish = new javax.swing.JButton();
        Clear = new javax.swing.JButton();
        NanduScoringSystem = new javax.swing.JRadioButton();
        TraditionalScoringSystem = new javax.swing.JRadioButton();
        CompulsoryScoringSystem = new javax.swing.JRadioButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel2.setBackground(new java.awt.Color(102, 0, 0));
        jPanel2.setMinimumSize(new java.awt.Dimension(800, 600));
        jPanel2.setPreferredSize(new java.awt.Dimension(820, 620));
        jPanel2.setLayout(new java.awt.GridBagLayout());

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setMinimumSize(new java.awt.Dimension(780, 580));
        jPanel1.setPreferredSize(new java.awt.Dimension(800, 600));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        nameL.setFont(new java.awt.Font("Bitstream Vera Sans", 0, 24)); // NOI18N
        nameL.setForeground(new java.awt.Color(51, 51, 255));
        nameL.setText("Name");
        jPanel1.add(nameL, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 110, -1, 40));

        mistakeL.setFont(new java.awt.Font("Bitstream Vera Serif", 0, 36)); // NOI18N
        mistakeL.setText("mistake");
        mistakeL.setMaximumSize(new java.awt.Dimension(800, 47));
        jPanel1.add(mistakeL, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 220, -1, -1));

        eventL.setFont(new java.awt.Font("Copperplate Gothic Bold", 0, 36)); // NOI18N
        eventL.setText("Event");
        jPanel1.add(eventL, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 70, -1, -1));

        deductionL.setFont(new java.awt.Font("Bitstream Vera Serif", 0, 36)); // NOI18N
        deductionL.setText("deduction");
        jPanel1.add(deductionL, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 450, -1, -1));

        finalScoreL.setFont(new java.awt.Font("Verdana", 0, 64)); // NOI18N
        finalScoreL.setForeground(new java.awt.Color(0, 0, 204));
        finalScoreL.setText("final");
        jPanel1.add(finalScoreL, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 500, -1, -1));

        scoreBL.setFont(new java.awt.Font("Bitstream Vera Serif", 0, 36)); // NOI18N
        scoreBL.setText("score B");
        jPanel1.add(scoreBL, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 350, -1, -1));

        groupGenderL.setFont(new java.awt.Font("Copperplate Gothic Bold", 0, 36)); // NOI18N
        groupGenderL.setText("Gender");
        jPanel1.add(groupGenderL, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 40, -1, -1));

        mistakeT.setFont(new java.awt.Font("Courier", 1, 18)); // NOI18N
        mistakeT.setLineWrap(true);
        mistakeT.setWrapStyleWord(true);
        jScrollPane1.setViewportView(mistakeT);

        jPanel1.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 170, 580, 130));

        scoreCL.setFont(new java.awt.Font("Bitstream Vera Serif", 0, 36)); // NOI18N
        scoreCL.setText("score C");
        jPanel1.add(scoreCL, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 400, -1, -1));

        scoreAL.setFont(new java.awt.Font("Bitstream Vera Serif", 0, 36)); // NOI18N
        scoreAL.setText("score A");
        jPanel1.add(scoreAL, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 310, -1, -1));

        genderF.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jPanel1.add(genderF, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 40, 580, -1));

        eventF.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jPanel1.add(eventF, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 80, 580, -1));

        nameF.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jPanel1.add(nameF, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 120, 540, -1));

        scoreAF.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jPanel1.add(scoreAF, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 319, 410, 30));

        scoreBF.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        scoreBF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                scoreBFActionPerformed(evt);
            }
        });
        jPanel1.add(scoreBF, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 360, 410, -1));

        scoreCF.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jPanel1.add(scoreCF, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 410, 410, -1));

        deductionF.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jPanel1.add(deductionF, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 460, 390, -1));

        finalF.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jPanel1.add(finalF, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 530, 520, -1));

        Publish.setText("Publish");
        Publish.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PublishActionPerformed(evt);
            }
        });
        jPanel1.add(Publish, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 570, -1, -1));

        Clear.setText("Clear");
        Clear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ClearActionPerformed(evt);
            }
        });
        jPanel1.add(Clear, new org.netbeans.lib.awtextra.AbsoluteConstraints(680, 570, -1, -1));

        NanduScoringGroup.add(NanduScoringSystem);
        NanduScoringSystem.setSelected(true);
        NanduScoringSystem.setText("Nandu Scoring System");
        NanduScoringSystem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NanduScoringSystemActionPerformed(evt);
            }
        });
        jPanel1.add(NanduScoringSystem, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, -1, -1));

        NanduScoringGroup.add(TraditionalScoringSystem);
        TraditionalScoringSystem.setText("Traditional Scoring System");
        TraditionalScoringSystem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TraditionalScoringSystemActionPerformed(evt);
            }
        });
        jPanel1.add(TraditionalScoringSystem, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 10, -1, -1));

        NanduScoringGroup.add(CompulsoryScoringSystem);
        CompulsoryScoringSystem.setText("Compulsory Scoring System");
        CompulsoryScoringSystem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CompulsoryScoringSystemActionPerformed(evt);
            }
        });
        jPanel1.add(CompulsoryScoringSystem, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 10, -1, -1));

        jPanel2.add(jPanel1, new java.awt.GridBagConstraints());

        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ClearActionPerformed

        genderF.setText("");

        //set event
        eventF.setText("");
        
        //set name
        nameF.setText("");
       
        //get mistake
        mistakeT.setText("");
        
        scoreBF.setText("");
        
      
        scoreAF.setText("");
        scoreCF.setText("");

        
        deductionF.setText("");
        finalF.setText("");
        
    }//GEN-LAST:event_ClearActionPerformed

    private void PublishActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PublishActionPerformed
       
        //if the form doesn't exist create one
        if(finalSummary==null)
            finalSummary=new Summary(null, false);
                
        //make final summary visible
        if (finalSummary.isVisible() == false)
            finalSummary.setVisible(true);
        
        //clear previous data if any
        finalSummary.clear();
        
        //add data to the form
        finalSummary.setGroupGender(genderF.getText());

        //set event
        finalSummary.setEvent(eventF.getText());
        
        //set name
        finalSummary.setName(nameF.getText());
       
        //get mistake
        finalSummary.setMistake(mistakeT.getText());
        
        if(globalData.scoringSystemType==0)// 0 traditional, 1 nandu, 2 compulsory
        {
           
        }
        if(globalData.scoringSystemType==1)// 0 traditional, 1 nandu, 2 compulsory
        {
            finalSummary.setScoreA(scoreAF.getText());
            finalSummary.setScoreC(scoreCF.getText());
            finalSummary.setScoreB(scoreBF.getText());
        }
        else
        {
            finalSummary.setScoreA(scoreAF.getText());
            finalSummary.setScoreB(scoreBF.getText());
        }
        
        
        
        finalSummary.setDeduction(deductionF.getText(), "");
        finalSummary.setFinalScore(finalF.getText());
        
    }//GEN-LAST:event_PublishActionPerformed

    private void scoreBFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scoreBFActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_scoreBFActionPerformed

    private void NanduScoringSystemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NanduScoringSystemActionPerformed
        globalData.scoringSystemType=1;// 0 traditional, 1 nandu, 2 compulsory
        scoreAF.setEnabled(true);
        scoreCF.setEnabled(true);
        scoreAL.setEnabled(true);
        scoreCL.setEnabled(true);
        scoreBL.setEnabled(true);
        scoreBL.setEnabled(true);
    }//GEN-LAST:event_NanduScoringSystemActionPerformed

    private void CompulsoryScoringSystemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CompulsoryScoringSystemActionPerformed
        globalData.scoringSystemType=2;// 0 traditional, 1 nandu, 2 compulsory
        scoreAF.setEnabled(true);
        scoreCF.setEnabled(false);
        scoreAL.setEnabled(true);
        scoreCL.setEnabled(false);
        scoreBL.setEnabled(true);
        scoreBL.setEnabled(true);
    }//GEN-LAST:event_CompulsoryScoringSystemActionPerformed

    private void TraditionalScoringSystemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TraditionalScoringSystemActionPerformed
        globalData.scoringSystemType=0;// 0 traditional, 1 nandu, 2 compulsory
        scoreAF.setEnabled(false);
        scoreCF.setEnabled(false);
        scoreAL.setEnabled(false);
        scoreCL.setEnabled(false);
        scoreBL.setEnabled(true);
        scoreBL.setEnabled(true);
    }//GEN-LAST:event_TraditionalScoringSystemActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Input(new javax.swing.JFrame(), true).setVisible(true);
            }
        });
    }
   
 
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Clear;
    private javax.swing.JRadioButton CompulsoryScoringSystem;
    private javax.swing.ButtonGroup NanduScoringGroup;
    private javax.swing.JRadioButton NanduScoringSystem;
    private javax.swing.JButton Publish;
    private javax.swing.JRadioButton TraditionalScoringSystem;
    private javax.swing.JTextField deductionF;
    private javax.swing.JLabel deductionL;
    private javax.swing.JTextField eventF;
    private javax.swing.JLabel eventL;
    private javax.swing.JTextField finalF;
    private javax.swing.JLabel finalScoreL;
    private javax.swing.JTextField genderF;
    private javax.swing.JLabel groupGenderL;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel mistakeL;
    private javax.swing.JTextArea mistakeT;
    private javax.swing.JTextField nameF;
    private javax.swing.JLabel nameL;
    private javax.swing.JTextField scoreAF;
    private javax.swing.JLabel scoreAL;
    private javax.swing.JTextField scoreBF;
    private javax.swing.JLabel scoreBL;
    private javax.swing.JTextField scoreCF;
    private javax.swing.JLabel scoreCL;
    // End of variables declaration//GEN-END:variables
    
}
